package service.impl;

import java.sql.SQLException;
import java.util.List;

import dao.impl.DatabaseDaoImpl;

import bean.Ajax;
import entity.Database;
import entity.Tables;
import service.DatabaseService;
import utils.DbBackUtil;

public class DatabaseServiceImpl implements DatabaseService {
	
	DatabaseDaoImpl databaseDao = new DatabaseDaoImpl();

	@Override
	public Ajax<Database> getList() throws SQLException {
		Ajax<Database> ajaxDatabase = new Ajax<Database>();
		List<Database> list = databaseDao.getList();
		ajaxDatabase.setRows(list);
		int total = list.size();
		ajaxDatabase.setTotal(total);
		return ajaxDatabase;
	}

	public int Optimize(String table) throws SQLException {
		return databaseDao.doRepair(table);
	}

	public int doOptimize(String table) throws SQLException {
		return databaseDao.doOptimize(table);
	}

	@Override
	public int doRepair(String table) throws SQLException {
		return databaseDao.doRepair(table);
	}

	public int doBackDatabase() throws Exception {
		
		return 1;
	}

}
